const mysql = require('mysql2');
import config from "../config";

// 配置项：请根据你的数据库实际情况修改这些配置
const dbconfig = {
    host: config.mysql.host,
    username: config.mysql.username,
    password: config.mysql.password,
    database: config.mysql.database,
    port: config.mysql.port,
};
export async function initializePool(): Promise<void> {
    try {
        let db_pool = mysql.createPool(dbconfig);
        console.log("===>mysql连接池已初始化");
        return db_pool.promise();
    } catch (err) {
        console.error('===>mysql连接池初始化失败:', err);
        throw err;
    }
}


